/*
 * Copyright 2024-2025 Embabel Software, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.embabel.agent.rag.model

import io.swagger.v3.oas.annotations.media.Schema

/**
 * Root of all data objects.
 * Data object instance, whether structural (from a literal source)
 * or not.
 */
sealed interface Datum {

    /**
     * Embabel id. Will be synthetic.
     */
    val id: String

    /**
     * URI for the content. May be a URL.
     * Not generated by Embabel, but from the source.
     */
    val uri: String?

    val metadata: Map<String, Any?>

    /**
     * Properties to persist
     * Subclasses can add their own properties
     * but must call super to include these.
     */
    fun propertiesToPersist(): Map<String, Any?> = mapOf(
        "id" to id,
        "uri" to uri,
    ) + metadata

    /**
     * Labels of the entity. In Neo, this might include multiple labels.
     * In a relational database, this might be a single table name.
     */
    @Schema(
        description = "Labels of the content element. In Neo, this might include multiple labels. In a relational database, this might be a single table name.",
        example = "[\"Person\", \"Customer\"]",
        required = true,
    )
    fun labels(): Set<String> = emptySet()
}
